﻿using UnityEngine;
using System.Collections;

namespace DragonRescue3D
{
    /// <summary>
    /// Sound button class which toggles the game sounds on/off and sets the appropriate button texture
    /// </summary>
    public class SoundBtn : MonoBehaviour
    {
        bool _soundOn;
        GamePlayManager _gamePlayManager;
        public Material OnBtnMat;
        public Material OffBtnMat;

        //--------------------------------------------------------
        /// <summary>
        /// makes sure we have the correct material assigned to the sound button at start-up 
        /// </summary>
        void Start()
        {
            _gamePlayManager = FindObjectOfType(typeof(GamePlayManager)) as GamePlayManager;
            _soundOn = _gamePlayManager.IsSoundActive;

            // If the sound is turned on make sure the sound button texture is correct 
            if (_soundOn == true)
            {
                GetComponent<Renderer>().material = OnBtnMat;
            }
            else
            {
                GetComponent<Renderer>().material = OffBtnMat;
            }
        }

        //--------------------------------------------------------
        /// <summary>
        /// Toggles the game sound preference and button material when the associated button/game object is pushed
        /// </summary>
        void OnMouseDown()
        {
            _soundOn = !_soundOn;

            if (_soundOn == true)
            {
                GetComponent<Renderer>().material = OnBtnMat;
                _gamePlayManager.ActivateSounds(true);
            }
            else
            {
                GetComponent<Renderer>().material = OffBtnMat;
                _gamePlayManager.ActivateSounds(false);
            }
        }
    }
}

#if NO_AND_ERROR
public void TEXT1() 
{
	int textNum = 1;
	if (textNum == 1) 
	{
		textNum = 2;
    }
}
public void TEXT2()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}
public void TEXT3()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT4()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT5()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT6()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT8()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT9()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT10()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT11()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT12()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT13()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT14()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT15()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT16()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT17()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}
#endif
